#include <buola/chart/cxychart.h>
#include <buola/chart/plots/clineplot.h>
#include <buola/chart/plots/cscatterplot.h>
#include <buola/app/capp.h>

using namespace buola;

int main(int pNArg,char **pArgs)
{
    buola_init(pNArg,pArgs);

    try
    {
        CApp lApp;
        chart::PXYChart lChart=new chart::CXYChart;
        chart::PLinePlot lPlot1=new chart::CLinePlot;
        
        std::vector<double> lX;
        for(int i=1;i<=100;i++) lX.push_back(i);
        
        mat::CVec_d lY1=mat::random(100,1,std::normal_distribution<double>(0.3,0.5));
        lPlot1->SetSeries(new chart::CSeries(lX,lY1));
        lPlot1->SetName(L"a plot");
        
        chart::PLinePlot lPlot2=new chart::CLinePlot;
        
        mat::CVec_d lY2=mat::random(100,1,std::normal_distribution<double>(3.0,1.5));
        lPlot2->SetSeries(new chart::CSeries(lX,lY2));
        lPlot2->SetName(L"another plot");
        lPlot2->SetColor(img::CColor(L"steelblue"));
        
        lChart->AddPlot(lPlot1);
        lChart->AddPlot(lPlot2);
        lChart->ToggleLegend();
        lChart->Map(CSize_d(800,600));
        
        lApp.Run();
    }
    catch(std::exception &pE)
    {
        msg_info() << pE.what() << "\n";
    }

    return buola_finish();
}